<%@ page import="model.MovieSection"%>
<table id="seatingPlan">
    <tbody>
        <%@ page import="java.util.List"%>
        <%!
            private boolean isExist(String seatNo, List<String> list) {
                for (String curr : list) {
                    if (curr.equals(seatNo)) {
                        return true;
                    }
                }
                return false;
            }
        %>
        <%
                    MovieSection target = (MovieSection) session.getAttribute("targetMovieSection");
                    String houseId = target.getHouseId();
                    int numRow = 0, numCol = 0;
                    if (houseId.equals("house 1") || houseId.equals("house 2") || houseId.equals("house 3")) {
                        numRow = 10;
                        numCol = 10;
                    } else if (houseId.equals("house 4") || houseId.equals("house 5")) {
                        numRow = 6;
                        numCol = 10;
                    } else {
                    }
                    char charRow = 'A';
                    List<String> occupiedSeats = (List<String>) session.getAttribute("occupiedSeats");
                    List<String> reservedSeats = (List<String>) session.getAttribute("reservedSeats");
                    for (int row = 0; row < numRow; row++) {
                        out.print("<tr>");
                        for (int col = 0; col < numCol; col++) {
                            String seatNo = Character.toString(charRow) + col;
                            if (isExist(seatNo, occupiedSeats)) {
        %>
    <td>
        <input class="seat" id="<%=seatNo%>" type="button" value="<%=seatNo%>" name="<%=seatNo%>" disabled="true" style="background: #FFF" onclick="return false;" />
    </td>
    <%
                                } else if (isExist(seatNo, reservedSeats)) {
    %>
    <td>
        &nbsp;
    </td>
    <%                                } else {
    %>
    <td>
        <input class="seat" id="<%=seatNo%>" type="button" value="<%=seatNo%>" name="<%=seatNo%>" onclick="return chooseSeats(this)" />
    </td>
    <%
                        }
                    }

                    out.print("</tr>");
                    charRow++;

                }
    %>
</tbody>
</table>
